import time from './time'
export default class Song {
	constructor({ id, name, mvId, alia, album, singer, duration, url, vip, license, publishTime, index }) {
    this.id = id,
    this.name = name,
    this.mvId = mvId,
    this.alia = alia,
    this.singer = singer,
    this.duration = duration,
    this.url = url,
    this.vip = vip,
    this.license = license,
    this.publishTime = publishTime,
    this.album = album,
    this.index = index
  }
}

export function formartSongInfo(params, index){
  return new Song({
    id: String(params.id),
    name: params.name,
    mvId: params.mv,
    alia: params.alia,
    singer: params.ar,
    album: params.al,
    vip: params.fee === 1,
    license: params.license,
    duration: time.formatSongTime(params.dt),
    url: `https://music.163.com/song/media/outer/url?id=${params.id}.mp3`,
    publishTime: time.formatMsgTime(params.publishTime),
    index: index + 1
  })
}
